Skip to content

fix(quota): fence historical ACK writeback order by GoalRef - #8975

Merged
loopx-agent merged 5 commits into
mainfrom
cursor/fix-historical-ack-writeback-goalref-4922
Nov 18, 2026
Merged

loopx-agent merged 5 commits into
mainfrom
cursor/fix-historical-ack-writeback-goalref-4922

Conversation

@Duang777

@Duang777 Duang777 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

  • Outcome basis / optional anchor: Self-found by reading main, then extended after review on this PR. Not taken from an issue list. duang777 (@Duang777) did not claim or close any issue.
  • Goal/source and gap: Historical ACK recovery was not GoalRef-fenced. Rebuilding that review after a retired-instance ACK must keep the same progress-review policy and effective-turn cadence the status projection used.
  • Observable before → after, with the validation row that proves it: An owned same-second ACK still records historical_ack_recorded. Only a retired ACK leaves File and SQLite quota should-run on replan_required. With progress_review.mode=assist and a retired ACK, the same Turn's second quota should-run stays rc=0 and autonomous_replan_required on the admitted obligation, instead of heartbeat_receipt_identity_conflict. An explicit empty candidate list still means no owned historical ACK. The frontier builder stays within its decision-point budget.
  • Issue/task and intended base: Related to fix(replan): accept a same-second whole-second historical ACK #8804 and Keep historical ACK admission on the original heartbeat receipt #8907. This pull request must not close Keep historical ACK admission on the original heartbeat receipt #8907 or any issue. Base is main. Keep historical ACK admission on the original heartbeat receipt #8907 is already merged; this branch merges that admission clock in and keeps the GoalRef fence beside it.

Author Declaration

  • Written by: duang777 (@Duang777); agent (Grok 4.7)

Implemented against

  • Specification and revision: no written specification; the request in this PR is the basis
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
Owned same-second ACK is recorded; a retired-only ACK leaves the original replan implemented autonomous_replan_ack.py, semantic_history.py settlement CLI tests
Progress-review reentry keeps the admitted obligation beside a retired ACK implemented live_decision.py _restore_replan_obligation_without_foreign_acks test_progress_review_reentry_keeps_the_admitted_obligation_beside_a_retired_ack
Frontier builder stays within the decision-point budget implemented receipt_bound_replan_ack_history maintainability ratchet smoke
Keep #8907's original-receipt admission clock and the GoalRef fence together implemented admission_event_id forwarded with goal_ref test_same_turn_receipt_upgrade_keeps_historical_ack_admission and the GoalRef ACK tests
  • Self-check before submission: Reproduced the assist-mode reentry conflict, then passed the same Turn's second should-run after restoring external_progress_review and effective_turn_cadence. After merging current main, the same GoalRef decisions still pass and the merged admission-clock test passes.

Scope And Continuation

Validation

  • Tested revision: 7771509f92ff672474214b85d6f21adb3ce1a376
  • Run state: finished
  • Input classes: synthetic
Check kind Result Public-safe evidence / limitation
regression_parity passed uv run --extra test python -m pytest tests/control_plane/test_autonomous_replan_ack.py plus the retired-instance, progress-review reentry, same-second, and same-Turn upgrade settlement CLI tests: 36 passed.
static passed ruff check on the resolved ACK, live-decision, writeback, and test files. git diff --check. scripts/check_rfc_bilingual.py --base origin/main --head HEAD passed.
  • Coverage and gaps: This head is a merge of origin/main, not a rebase. Pushed history was not rewritten. The maintainability ratchet was not re-run on this merge commit; the frontier selection path was not part of the conflict resolution.

Frontend / Visual Evidence

  • UI impact: none
  • Before: N/A
  • After: N/A
  • First viewport and preview: N/A
  • States and viewports shown: N/A
  • Source data: none
  • Attention review: N/A
  • Craft review: N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring (no functional changes)
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)
  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)
  • Capability or extension (providers, adapters, skills)
  • Public docs or presentation surface (README, protocols, dashboard)
  • Build, packaging, installer, or CI
  • Host or runtime integration

Technical Direction

  • Direction / acceptance reference, when applicable: Core control-plane hardening. No roadmap id invented.

Shared-authority RFC fixture impact

N/A

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.
  • I completed the visual evidence section for UI changes, or marked UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).
Open in Web Open in Cursor 

Same-goal instances share one rollout log. The historical ACK reader bound
the first matching refresh, so a retired instance's earlier writeback could
clear writeback_follows_admission and drop the current same-second ACK.
Keep only the quota owner's own events and run-index rows.

Signed-off-by: Duang777 <duangjl007@gmail.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google (self_reported)

已针对 PR #8975 exact head c8877c21fbda45ea614646fdbc5668acec50dc54 完成完整代码审查、调用方梳理与本地验证(审查结论:APPROVE,无 P0/P1 阻断问题,附 1 项已披露边界内的非阻断 P2 关注项)。

动机 / Motivation

受影响调用方与运维者:共享同一 goal_id 目录(goals/<goal_id>/rollout-event-log.jsonl 与 goals/<goal_id>/runs/index.jsonl)的多实例 Goal、别名(alias)配额调用方以及 quota should-run / refresh-state(loopx/control_plane/quota/live_decision.py、loopx/control_plane/work_items/semantic_replan_writeback.py、loopx/state_refresh.py)。

修改前(main 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d):autonomous_replan_ack.py 的历史 ACK 回写顺序读取器未按 goal_ref 隔离日志与运行索引,而 obligation_id 哈希不含 goal_instance_id 且允许跨实例复用 Turn。当同秒历史 ACK 触发精确回写顺序校验时,已退役实例更早的 refresh_state 会抢先绑定并把 writeback_follows_admission 判为 false,导致当前别名或新实例 quota should-run 以 heartbeat_receipt_identity_conflict(exit 1)误拒。修改后(c8877c21fbda45ea614646fdbc5668acec50dc54):仅保留与调用方 goal_ref(或 alias 无 goal_ref)一致的事件与运行索引行,并从 live_decision.py、semantic_replan_writeback.py 与 state_refresh.py 传入 goal_ref。

可观测结果:精确 goal_ref 所有者在混杂共享日志中准确从自身 fresh_vision_path_outcome 恢复 historical_ack_recorded(不被已退役实例的 new_surface 或无 goal_ref 行干扰),同日志下别名调用方被正确拒绝;真实 CLI quota should-run 在存在已退役实例先序 refresh_state 时返回 exit 0 且 replan_action_packet.decision == "historical_ack_recorded"。本地 ruff(6 个变更文件)、mypy(17 个源文件)、typecheck:control-plane、replan_semantics.test.ts(41 passed)、9 组控制面 pytest(400 passed in 404.71s)、canary premerge --tier quick(selected=3, failures=0)与 loopx check --scan-path(errors=0, warnings=0)全部通过。

非目标边界:本 PR 不修改 #8907 的 admission-clock(admission_event_id)规则,不修改 status/collection.py、run_context_retention.py 或 goal_frontier/__init__.py:1684 中从 status_payload 另行追加 latest_agent_replan_ack 的通用状态投影,也不改变通用 source_session_v1 注册表读取约束。

改动思路 / Approach

将历史 ACK 回写顺序的 goal_ref 所有权判定集中保留在 loopx/control_plane/work_items/autonomous_replan_ack.py 内部,通过 _owner_goal_ref 与 _record_owned_by_goal_ref 精确对齐 TypeScript quotaOwnerOwnsProjection(alias 仅匹配缺失 goal_ref 的记录,exact 匹配经 exact_goal_ref 校验的精确实例且校验 goal_id 一致),再由 live_decision.py、semantic_replan_writeback.py 与 state_refresh.py 透传既有 goal_ref 参数,不新增第二套读取器或持久化字段。

当前 PR 边界:只限定在 autonomous_replan_ack.py 的事件/运行索引按 goal_ref 过滤、live_decision.py / semantic_replan_writeback.py / state_refresh.py 的 goal_ref 透传以及两组回归测试文件,保持 status_payload 与 goal_frontier 既有 latest_agent_replan_ack 投影及 #8907 admission-clock 语义不动。

归属与记录形态 base (513b6f16) exact head (c8877c21)
Exact goal_ref 所有者读到已退役实例先序 refresh_state 错误绑定退役实例事件并覆盖 writeback_follows_admission 过滤非本实例行,仅绑定自身事件并产出 historical_ack_recorded
Alias 所有者(goal_ref=None)读到带 goal_ref 的退役实例事件 同秒 quota should-run 误报 heartbeat_receipt_identity_conflict 仅保留 'goal_ref' not in record,CLI 返回 exit 0 与 historical_ack_recorded
goal_ref 与 goal_id 不一致或格式非法 无校验 _owner_goal_ref 立即 fail-closed 抛出 ValueError

具体改动 / Changes

本次 diff 共触及 6 个文件(+299 / -10 行,其中生产代码 +94 / -10 行、测试 +205 / -0 行),无 RFC 文件变更。无独立书面 spec;对照 PR 目标及既有权威所有权实现 quotaOwnerOwnsProjection 评估:exact/alias 语义对齐(implemented)、同秒 alias should-run 恢复(implemented)、全部直接调用方透传 goal_ref(implemented)、保持 #8907 admission-clock 不变(implemented)。

关键代码讲解

  1. _owner_goal_ref / _record_owned_by_goal_ref / _owned_records(autonomous_replan_ack.py:277-322):复用 exact_goal_ref 校验非空精确实例并阻止跨 goal_id 越界;alias 模式要求 'goal_ref' not in record(与 TypeScript quotaOwnerOwnsProjection 的 value === undefined 在 JSON 语义上等价,null 或畸形对象均被拒绝)。
  2. attach_historical_ack_writeback_order / historical_ack_candidates_with_writeback_order / load_receipt_replan_ack_candidates(autonomous_replan_ack.py:324-558):在构建候选项与查找 _admission_event_index、_source_run、_expected_todo_receipt、_writeback_event_is_bound 之前统一用 _owned_records 和 _record_owned_by_goal_ref 过滤 events 与 runs,保证事件索引顺序对比在同一所有者子集内完成。
  3. build_live_quota_should_run_decision(live_decision.py:796-801)与 qualify_replan_writeback / enforce_open_replan_writeback / qualify_refresh_replan_writeback、state_refresh.py:1141-1142:全仓 rg 核实这三处已覆盖上述函数的全部生产调用方。

对主干的风险 / Risks

  • [P2 / 非阻断] qualify_replan_writeback 合成的 status_payload 仍含未按 goal_ref 过滤的 newest_first_runs:在精确 head 上直接探针调用 enforce_open_replan_writeback / qualify_replan_writeback(semantic_replan_writeback.py:286-296)确认,若 runs/index.jsonl 存在 generated_at 严格晚于准入时间(preciseLater)的已退役实例 ACK,goal_frontier/__init__.py:1684 仍会通过 latest_agent_replan_ack 命中该退役 ACK;而 quota should-run CLI 路径因 run_context_retention.py:50-54 剥离了 turn_instance_id 故不会误命中。鉴于该问题在 main@513b6f16 已存在且 PR Scope 已明确将其划出本次写回顺序读取器范围,不作为本 PR 阻断项,建议在后续 goal_frontier / state_refresh 收敛 goal_ref 时补齐对 newest_first_runs 的过滤。
  • 本地与 CI 验证明细(exact head c8877c21fbda45ea614646fdbc5668acec50dc54):
    • PASS uv run --extra test ruff check(6 个修改文件):All checks passed!。
    • PASS uv run --extra test mypy:Success: no issues found in 17 source files。
    • PASS npm run typecheck:control-plane:tsc --project tsconfig.control-plane.json --noEmit 0 错误。
    • PASS node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/replan_semantics.test.ts:41 passed(0 failed)。
    • PASS uv run --extra test python -m pytest -q -n 4(test_autonomous_replan_ack.py、test_replan_semantics_transport.py、test_refresh_state_replan_gate.py、test_replan_successor_durable_ack.py、test_effective_turn_replan.py、test_canonical_planning_consumers.py、test_vision_wait_coverage.py、test_effect_turn_live_quota_decision.py、test_quota_settlement_cli.py):400 passed in 404.71s(0 skipped)。
    • PASS uv run --extra test loopx canary premerge --tier quick --from-git-diff --git-diff-base 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d:ok=true, selected=3, failures=0(3 个 smoke 全过)。
    • PASS loopx check --scan-path ...(6 个变更文件):ok=True (errors=0, warnings=0)。
    • DIAGNOSTIC(非本 PR 回归):GitHub Actions kernel-static-checks 失败日志核实仅报 main@513b6f16 既有的 tests/control_plane/test_contract_health.py:10:25 F401(由 #8974/#8969 修复);其余 7 项非绿色检查为 CANCELLED(loopx-core、loopx-codex-provider-routing、browser (1-3/3)、stage2c-correctness-e2e、checks),属独立合入门禁限制。

语义与 CI 对齐

本 PR 复用既有 goal_ref 与 quotaOwnerOwnsProjection 所有权契约,未新增任何状态枚举、持久化字段或命令行开关,词表漂移 smoke(semantic-vocabulary-drift-smoke.py)通过,语义保持完全对齐(candidate_decision="reuse_existing")。

我的整体评价 / Verdict

  • Long-horizon 影响:improved — 阻止同 goal_id 共享日志下已退役实例历史 refresh_state 破坏当前实例或别名所有者的同秒历史 ACK 恢复判定,减少长程恢复误拒与重复规划。
  • User-experience 影响:not_applicable — 内部配额与历史 ACK 读路径修复,无界面或交互输出格式改动,visual_review 为 not_applicable。
  • 可观测语义 / 复用 / 词表:observable_semantics 为 equivalent(仅修复跨 goal_ref 串扰),repository_reuse 为 reused,default_off_isolation 为 not_applicable(无可选开关,按既有 goal_ref 是否传入无条件隔离),authority_semantics 与 semantic_alignment 均为 aligned(candidate_decision="reuse_existing"),code_volume 为 necessary(compatibility_assessment.decision="retain"),change_proportionality 为 proportionate(architecture_assessment.decision="retain")。

改动能准确收敛共享日志下历史 ACK 回写顺序的 goal_ref 边界、调用方透传完整且本地验证全绿,予以 APPROVE;kernel-static-checks 合入门禁待合入 #8974 或重跑消除。

English verdict: APPROVE exact head c8877c2; cleanly fences historical ACK writeback order by GoalRef matching quotaOwnerOwnsProjection across all direct callers with 400 pytest, 41 TS tests, mypy (17 files), ruff, and quick premerge passing (remote kernel-static-checks failure is strictly the pre-existing F401 on main@513b6f16; non-blocking P2 tracks synthetic status_payload latest_runs filtering in semantic_replan_writeback.py).

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | model=gpt-6.2-sol | provider=OpenAI | reasoning_effort=max | source=runtime_reported

[P2] 旧实例的最新 ACK 仍可阻断本实例恢复。 File 与 SQLite 都复现。只有旧实例记录时,当前头返回身份冲突;同一输入去掉该记录后,原轮次仍可继续重规划。候选收集 · 追加最新 ACK 的分支

动机 / Motivation

使用 CLI 恢复重规划轮次的 Agent 和操作者需要继续原工作,并保留原有的回执与配额身份。 恢复短时间内完成重规划的原轮次时,旧 Goal 实例的记录可能与当前实例同名。同一秒内,主干有时舍弃属于本实例的确认,导致已完成的步骤无法接续。 ACK 是已写入的重规划确认。恢复只使用同一 Goal 实例的持久确认;只有其他实例的记录时,原重规划继续等待当前实例的有效确认。 有效本实例确认的恢复已经修正。只有旧实例确认时,原轮次仍会错误进入身份冲突。 本次范围限于原重规划写回及恢复顺序,不涉及准入时钟规则、安装或新执行权限。

改动思路 / Approach

在输入读取时应用既有 GoalRef 归属规则,然后只让同一批来源进入既有语义决策,可保持同秒顺序与原结算身份。 改动应闭合历史确认候选、轮次恢复和写回资格三个现有调用点,保留各自的权限与配额职责。 原 Turn 回执给出实例、Agent 与义务,Python 从既有 run index 和事件日志收集原写回,TypeScript 决定哪项历史确认可以用于结算。仅修准入时间不能避免读取另一个实例的记录。现有实现已修复存在有效本实例 ACK 的场景,可以在原候选边界补齐只有旧记录的情形。

具体改动 / Changes

审阅提交 c8877c21fbda45ea614646fdbc5668acec50dc54,实际基线 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d,共 6 文件,+299/-10。四个运行时改动传递 GoalRef 或过滤历史,两处测试覆盖相同秒写回。采用既有 重规划契约,spec_ref docs/reference/protocols/goal-vision-replan-contract-v0.md,spec_revision 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d。

  • ACK ownership 未满足。只有匹配本实例的确认可以影响该轮结算,最新运行的兼容分支仍可能引入旧实例历史。
  • Original Turn 已在本实例确认的真实恢复路径验证。恢复保留原绑定,配额消耗仍由既有步骤决定。

关键代码讲解

对主干的风险 / Risks

用同一套真实 CLI 输入在 File 和 SQLite 对照。存在本实例的同秒 ACK 且更早处有旧实例写回时,主干报身份冲突,当前头均恢复为 historical_ack_recorded。只剩旧实例的较新确认时,主干误认确认,当前头却报 heartbeat_receipt_identity_conflict。两个版本移除旧实例记录后都返回 replan_required,应以此为预期,保留原轮次等待当前实例完成重规划。四种条件、两种后端、两个版本共 16 次决策,均没有扣额。同头批准已观察到写回分支的候选串扰,并判断 CLI 不受影响。上述独立 CLI 实测明确了当前分支的恢复阻塞。现有同头评审

另外实际执行 4 组原 refresh-state 对照,只有旧实例确认和无确认两组都写入成功且未扣额。当前已确认的阻塞发生在准入恢复。让已经提供的实例范围候选列表成为原轮次候选的唯一来源,包括该列表为空时。让 should-run 与 refresh-state 共用相同筛选,并保留未绑定旧调用的兼容路径。

语义与 CI 对齐

复用现有 GoalRef 词汇与 TS 结算规则。另有直接类型对照,合法数字字符串作为 Goal ID 时两边都接收,JSON 数字型的 Goal ID 仅新增 Python 路径接收。修复同一范围筛选时请保留与原生严格解析一致的原始字段类型。重验真实 quota should-run 和 refresh-state 的本实例、空历史及只有旧实例三组。定向 Python 41 项及 TS 41 项通过。预合并门 6 项直接检查执行,18 项选中检查执行,0 项未通过。保留首次环境导入失败记录,精确范围的重跑已通过。 最初的本地导入失败在主干和候选均出现,原因是当前解释器的安全路径开关不含 smoke fixture 目录。按相同来源补齐该目录后,未修改源码。将候选与更新后的主干 3c03e91 组合无冲突,单独重验两个后端的只有旧实例确认和无确认共四组,结论一致。本轮使用本地验证,未等待托管 CI。

我的整体评价 / Verdict

这是既有恢复链路上的有效增量,但长期接续和用户侧恢复仍待闭合。在输入读取时应用既有 GoalRef 归属规则,然后只让同一批来源进入既有语义决策,可保持同秒顺序与原结算身份。 改动应闭合历史确认候选、轮次恢复和写回资格三个现有调用点,保留各自的权限与配额职责。 现有源中缺少合法 ACK 时,原重规划须仍能推进。没有新增配置或人工确认,修改应保持范围窄,重放和结算沿用原 owner。已检查 CLI 决策、写回资格及 Goal frontier 投影。提案没有变更页面、布局或交互控件,视觉评审不适用。 精确实例的完整宿主采用、安装态运行和长期成本没有验证。

English verdict: REQUEST_CHANGES at c8877c21fbda45ea614646fdbc5668acec50dc54. The direct history lookup now restores an owned same-second ACK. With only a retired instance's ACK, the unscoped latest-run fallback still stops recovery instead of retaining the original replan in both File and SQLite.

A retired instance's newer confirmation was compacted without goal_ref, so
receipt recovery treated it as this owner's latest ACK and stopped the
original replan. Keep goal_ref on the run projection, drop unowned recorded
ACKs before rebuilding the open review, and use the supplied candidate list
even when that list is empty.

Signed-off-by: Duang777 <duangjl007@gmail.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | model=gpt-6.2-sol | provider=OpenAI | reasoning_effort=max | source=runtime_reported

[P2] 新增的 ACK 选择分支使 Goal frontier 超出复杂度上限。 build_goal_frontier_projection_context_from_status 在基线和上一版都是 58 个决策点,这次升到 62,上限是 60。现有 maintainability ratchet 在前两版均通过,在本 head 报 oversized_decision_function。请将 receipt-aware ACK 选择和旧候选回退提取到已有的 semantic-history 边界,保留显式空列表的语义。修后重跑该检查和 File、SQLite 的 guard / refresh 回归。 新增分支

动机 / Motivation

同一 Goal ID 换代后共享历史。恢复已准入 Turn 时,其他实例的回执会干扰本实例的同秒写回顺序。上一版挡住了抢占顺序的旧写回,只有旧实例有确认时仍会报 identity conflict。

重启后接手原轮次的 Agent 和操作者需要直接续跑,继续使用现有回执。之前只看到旧实例 ACK 时会报身份冲突,这版的 File 和 SQLite 都回到原有 replan_required。所属实例的同秒确认可以恢复,只有外实例确认时继续等待本轮有效证据。这次评审覆盖原轮次的 ACK 恢复和 writeback。准入时钟沿用原规则。当前剩余阻塞是 Goal frontier 新增分支超出复杂度上限。

改动思路 / Approach

在历史输入和写回资格使用同一 GoalRef 归属规则。提供候选列表即采用该范围,空列表表示没有本轮可用的历史确认。保留既有 quota/语义所有者、原 Turn 和持久回执。这个边界同时覆盖 guard 和 refresh,能闭合故障。将选择分支留在已有 semantic-history 边界即可满足前沿复杂度约束。

把 receipt-aware 选择和旧回退放进既有 semantic-history 边界,可保留显式空列表语义,并满足现有复杂度门。保留原历史候选读取、frontier 输入和写回资格三个调用点,继续复用原配额和持久回执。

具体改动 / Changes

  • Original Turn。以 docs/reference/protocols/goal-vision-replan-contract-v0.md 在 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d 的语义为准,恢复保留原有 Turn 和 owner。已用相同 File、SQLite fixture 检查,同秒有效确认可恢复,旧实例的更早写回无法抢先。
  • Open replan。只有旧实例确认时,两种后端都与无 ACK 一样返回 replan_required,无配额扣减。已在当前 head 验证 refresh-state 可继续写回;另含与 main 组合的 19 项定向测试。
  • 两个提交共 8 个路径,+524/−19。与上一评审 head 相比,这版把 GoalRef 保留到 compact run 投影,按归属清理 scoped history,并去掉候选为空时的历史回退。

关键代码讲解

  • load_receipt_replan_ack_candidates 从同一 run index 找候选,按 GoalRef 过滤后才附写回顺序。 候选入口
  • _restore_replan_obligation_without_foreign_acks 清理 guard status 中的外实例 ACK 后用现有 projector 恢复原义务。 恢复路径
  • qualify_replan_writeback 把同一归属筛选用于实际 refresh 资格,避免读时判断仍在 replan 而写时被历史 ACK 截断。 写回资格

对主干的风险 / Risks

本地 standard premerge 的 6 项直接检查通过,18 项选中检查中 1 项失败,即上面的复杂度门。用户相关正反路径均已在 File、SQLite 复跑,额外 193 项 TypeScript 测试通过。广跑中的两个 gitless workspace 断言在基线和 head 同样失败。GitHub CI 未纳入本结论。

语义与 CI 对齐

检查了现有 scope、显式空列表、原 Turn、无收费和无新权限。绑定后的最新 ACK 行为是本次有意修正,原有未绑定调用继续用既有路径。

我的整体评价 / Verdict

上一轮发现的 ACK 回归已经修复。我对 188a251724f8ebb25512eacd6485bcc52408576d 请求修改复杂度超限,其余恢复行为应保留。变更仅涉及 CLI 和服务投影,视觉检查不适用。

复验后应继续沿用原轮次和配额身份,并保持未绑定历史的读取兼容。

English verdict: REQUEST_CHANGES at 188a251724f8ebb25512eacd6485bcc52408576d. File and SQLite verify that the previous ACK regression is repaired. The revised frontier builder trips the existing 60-decision-point limit at 62. Move the receipt-aware selection to the existing semantic-history boundary and rerun the ratchet and recovery matrix.

The receipt-owned ACK choice and empty-list fallback stay on the semantic
history reader. The frontier builder keeps its existing decision-point budget.

Signed-off-by: Duang777 <duangjl007@gmail.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | model=gpt-6.2-sol | provider=OpenAI | reasoning_effort=max | source=runtime_reported

本 head 的阻塞发现均已修复。复杂度由上一版的 62 降为 57,上限为 60。File 和 SQLite 保留原重规划、所属 ACK 恢复和零额外扣减。

动机 / Motivation

重启后接手原轮次的 Agent 和操作者需要从原回执直接续跑。主干会让旧实例的记录占用同秒确认,这版仅用所属实例的证据恢复,从而保留有待完成的重规划。所属实例的同秒确认可以恢复,只有外实例确认时继续等待本轮有效证据。评审范围限于原轮次的 ACK 恢复和写回。准入时钟、权威存储和主机安装沿用现有流程。

改动思路 / Approach

把 receipt-aware 选择放进已有 semantic-history 模块,显式空列表仍表示没有本轮证据。保留原历史候选读取、frontier 输入和写回资格三个调用点,继续复用原配额和持久回执。相比调整时钟,按原拥有者筛选历史可以直接处理共享 run log 的碰撞,也能保留旧 alias 格式。最近一次修订仅调整历史选择的位置,实测恢复行为保持一致。

具体改动 / Changes

  • Original Turn。以 docs/reference/protocols/goal-vision-replan-contract-v0.md 在 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d 的固定版本为准。File、SQLite 同一原轮次的所属确认仍匹配同秒写回、原 Agent 和原义务,两后端均观察到零扣减。
  • Open replan。上一版的授权行为在新提交保留。只有旧实例的有效确认,或没有任何确认,两种后端都返回 replan_required。真实 refresh-state 的写回也通过。
  • 整个提案 9 个路径 +541/−20。最新修订只改 2 个路径,把历史选择从 context builder 移入既有的 semantic-history。57 个决策点通过维护性门。

关键代码讲解

  • load_receipt_replan_ack_candidates 读原 run index,只利用本 owner 的持久候选及其写回顺序。 历史候选
  • receipt_bound_replan_ack_history 保留缺失候选列表和显式空列表的区别。前者走现有最新 ACK 回退,后者继续保留原义务。 历史选择
  • qualify_replan_writeback 复用相同的归属匹配,在原 refresh 上继续应用有权的写回。 写回资格

对主干的风险 / Risks

当前 head 的真实 CLI 全部 8 个对照、一组 19 个 Python 回归、193 项 TypeScript 测试及类型检查通过。standard premerge 的 6 项直接检查及 18 项选中检查通过。与采样 main 组合后再跑同一组 19 项回归,结果一致。较宽的 gitless 测试在原基线和上一评审版本同一断言失败,保留为独立环境观察。GitHub CI 未纳入本结论。

语义与 CI 对齐

有候选时可能把首项在投影内部再带一次。现有语义判断按相同证据匹配并在首次成功退出,File、SQLite 对照均保持单次恢复及零额外扣减。当前范围内未观察到队列或持久状态变化。

我的整体评价 / Verdict

批准当前 427950a43a9eeb3067bc66061d6a287f6beee202。两轮发现均用精确提交和相同输入实测结清。主机安装和发布验收仍由原流程负责。本次只改运行时投影,视觉检查不适用。原 Turn、配额身份与未绑定历史的兼容得到了同一组检查覆盖。

English verdict: APPROVE at 427950a43a9eeb3067bc66061d6a287f6beee202. The revised history helper preserves owned ACK recovery and the foreign-only/no-ACK parity on File and SQLite. The frontier builder is within the existing complexity limit, and the exact-head standard premerge checks pass.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google (self_reported)

已针对 PR #8975 最新 exact head 427950a43a9eeb3067bc66061d6a287f6beee202 完成独立全量重审(核查 513b6f168a..427950a43a 共 9 文件 +540 / -20,以及对上一版 188a251724 的增量提交 427950a43a),结论为 REQUEST_CHANGES:427950a43a 已修复此前 goal_frontier 复杂度棘轮超限(62 -> 57 <= 60,前序两轮 P2 亦均已关闭),但 188a251724 在 live_decision.py 引入的 P1 阻断回归在 427950a43a 上依然存在且未受测试覆盖(已在当前 exact head 本地 CLI 实测稳定复现)。

阻断问题摘要(Findings First)

  1. [P1 · 阻断] _restore_replan_obligation_without_foreign_acks 重算义务漏传 external_progress_review / effective_turn_cadence,导致开启进度审查的 Turn 重入报错 heartbeat_receipt_identity_conflict(live_decision.py#L669-L733):
    • 触发条件:Goal 配置 progress_review.mode='assist'(或 replan_after_effective_turns 周期审查)且达到触发阈值,同时共享 runs/index.jsonl 中存在一条早先已退役实例(不同 goal_instance_id)的 autonomous_replan_ack 记录;同一 --turn-instance-id 连续两次调用 quota should-run(准入 + 重入)。
    • 实测对照:基线 513b6f168a 准入与重入均返回 rc=0 decision=autonomous_replan_required ob=replan-03088cd76d7af044;exact head 427950a43a 首次准入同样为 rc=0 decision=autonomous_replan_required ob=replan-03088cd76d7af044,但第二次重入进入 _restore_replan_obligation_without_foreign_acks 后清除 item["autonomous_replan_obligation"],并以默认 None 调用 attach_active_state_project_asset_fields(...)(漏传 attention_queue.py#L328-L341 透传的 external_progress_review 与 effective_turn_cadence,使 project_asset.py:269-283 未包装这两参数),造成义务丢失并被 TS 守卫以 rc=1 decision=skip error_code=heartbeat_receipt_identity_conflict 拒绝。
    • 最小修复:在 live_decision.py::_restore_replan_obligation_without_foreign_acks(或更上游投影前清理阶段)基于 registered_goal = load_goal_from_registry(registry_path, goal_id) 与 runtime_root 构造并传入 external_progress_review=external_progress_review_context(...) 与 effective_turn_cadence=effective_turn_cadence_context(...)(与 attention_queue.py:328-341 严格一致),并在 tests/control_plane/test_quota_settlement_cli.py 补充 progress_review.mode='assist' + 退役实例历史 ACK 重入保持 rc=0 的回归测试。

动机 / Motivation

受影响调用方与运维者:共享同一 goal_id 目录(rollout-event-log.jsonl 与 runs/index.jsonl)的多实例 Goal、alias(无 goal_ref)或精确 goal_ref 调用方,在存在未关闭 autonomous_replan_obligation(尤其开启 progress_review 或 replan_after_effective_turns 时)执行 quota should-run 与 refresh-state 的运维者与 Agent。

对比本 PR 历次提交:前次审查头 c8877c21fb 遗留两项 P2;随后 188a251724 修复了这两项但触发了函数复杂度超限(dps=62 > 60)与 live_decision.py 义务重算回归;最新提交 427950a43a 把 receipt ACK 选择抽离至 semantic_history.py::receipt_bound_replan_ack_history,使 build_goal_frontier_projection_context_from_status 降回 stmts=68, dps=57 <= 60(棘轮回归已修复),但 427950a43a 并未修改 live_decision.py。因此当 Goal 开启 progress_review(assist 模式)且 runs/index.jsonl 中存在一条早先已退役实例的 autonomous_replan_ack 时,干净基线 513b6f168a 上同一 Turn 连续两次调用 quota should-run 均稳定返回 rc=0 decision=autonomous_replan_required(replan-03088cd76d7af044),而 exact head 427950a43a 在首次准入为 rc=0 后,第二次重入时 _restore_replan_obligation_without_foreign_acks 清除原义务并漏传 external_progress_review / effective_turn_cadence,直接以 rc=1 error_code=heartbeat_receipt_identity_conflict 失败。

可观测结果:在 exact head 427950a43a9eeb3067bc66061d6a287f6beee202 上实测:ruff check(9 文件)与全仓 mypy(17 源码文件)Clean;test_maintainability_ratchet.py + test_autonomous_replan_ack.py + test_replan_semantics_transport.py + test_refresh_state_replan_gate.py 79 passed in 13.42s,test_quota_settlement_cli.py 211 passed in 135.59s(合计 290 passed);canary premerge --tier quick --from-git-diff --git-diff-base 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d 3 项目录金丝雀与 6 项直接检查全部通过(failures=0, ok=true);loopx check --scan-path ...(9 文件)公开边界扫描干净(errors=0)。但在真实 CLI 对抗复现中(开启 progress_review.mode='assist' + 2 条 drift 回执 + 1 条更早旧实例 ACK),基线 513b6f168a 准入与重入均为 rc=0 autonomous_replan_required,而 427950a43a 准入 rc=0,重入 rc=1 decision=skip error_code=heartbeat_receipt_identity_conflict。

非目标边界:本 PR 不修改 #8907 准入时钟(admission_event_id)边界,亦不扩展为跨实例历史读回迁移或关闭 #8907 / #8804。

改动思路 / Approach

架构与放置判断:以 drop_unowned_recorded_replan_acks 统一按 GoalRef 隔离已记录 ACK、并在 semantic_history.py::receipt_bound_replan_ack_history(而非 goal_frontier/__init__.py 内联分支)选择受限候选列表是清晰合理的架构位置;但 live_decision.py:669-733 引入了一处与 attention_queue.py:328-341 上下文参数不一致的局部二次重算旁路,在补全 external_progress_review 与 effective_turn_cadence 透传(或将过滤前置到投影之前)前不能合并。

当前 PR 边界:完整 513b6f168a..427950a43a(9 文件 +540 / -20)覆盖 GoalRef 过滤、run compaction、refresh 写回校验与 live reentry 恢复,不触及 #8907 准入时钟;待 live_decision.py P1 上下文漏传缺陷修复并补齐重入回归测试后即可收口。

  • 对增量提交 427950a43a 的核对:该提交将 scoped_ack_history 解析从 goal_frontier/__init__.py 抽离至 semantic_history.py::receipt_bound_replan_ack_history,使 build_goal_frontier_projection_context_from_status AST 度量回到 stmts=68, dps=57(<= 60),tests/canary/test_maintainability_ratchet.py 与 canary premerge --tier quick 转绿;但因未触及 live_decision.py,P1-1 在 427950a43a 上完整保留。另顺带观察(非阻断):goal_frontier/__init__.py:1681 删除 not isinstance(raw_historical_ack_candidates, list) 后当 owned 非空时会将首项多追加一次,TS 首次匹配先退出未改变结果,可在修 P1-1 时顺手保持去重整洁。

具体改动 / Changes

完整 diff(513b6f168a..427950a43a)共触及 9 个文件(+540 / -20,无 RFC 变更):

  1. loopx/control_plane/goals/goal_frontier/semantic_history.py(+32 / -0):新增 receipt_bound_replan_ack_history,区分未传候选列表与显式空列表。
  2. loopx/control_plane/goals/goal_frontier/__init__.py(+4 / -7,1961 行):改为调用 receipt_bound_replan_ack_history,dps 降至 57。
  3. loopx/control_plane/quota/live_decision.py(+72 / -1,1213 行):调用 load_receipt_replan_ack_candidates 并触发 _restore_replan_obligation_without_foreign_acks(存在 P1-1 漏参缺陷)。
  4. loopx/control_plane/work_items/autonomous_replan_ack.py(+117 / -9,766 行):实现 _parsed_exact_goal_ref、_owner_goal_ref、_record_owned_by_goal_ref 与 drop_unowned_recorded_replan_acks 并按 goal_ref 过滤候选。
  5. loopx/control_plane/work_items/semantic_replan_writeback.py(+13 / -3,657 行)与 loopx/control_plane/runtime/run_compaction.py(+1 / -0)及 loopx/state_refresh.py(+1 / -0):透传 goal_ref、在 RUN_BASE_COMPACT_FIELDS 保留 "goal_ref" 并过滤 qualify_replan_writeback 的 latest_runs。
  6. tests/control_plane/test_autonomous_replan_ack.py(+107 / -0)与 tests/control_plane/test_quota_settlement_cli.py(+194 / -0):覆盖同秒/仅旧实例(selected-todo)恢复与 GoalRef 解析测试,但缺失 progress_review / replan_after_effective_turns 重入回归用例。

关键代码讲解

  1. _restore_replan_obligation_without_foreign_acks(loopx/control_plane/quota/live_decision.py:669-733):清理 latest_runs 中非己方 goal_ref 的已记录 ACK 并弹出 item["autonomous_replan_obligation"] 后,L729-733 调用 attach_active_state_project_asset_fields 时遗漏了 external_progress_review 与 effective_turn_cadence,直接导致已开启 progress_review 的 Goal 在重入阶段退化为身份冲突失败。
  2. receipt_bound_replan_ack_history(loopx/control_plane/goals/goal_frontier/semantic_history.py:235-L265):在 receipt_bound_replan_obligation_id 存在且传入 list 类型候选时将 owned 作为完整受限历史,成功修复空列表回退至旧实例最新 ACK 的问题并将函数决策点控制回棘轮上限以内。
  3. drop_unowned_recorded_replan_acks(loopx/control_plane/work_items/autonomous_replan_ack.py:320-347):统一过滤他实例已记录 autonomous_replan_ack 历史行并保留普通运行记录与合法 alias/exact 行。

对主干的风险 / Risks

  • P1 阻断回归直接威胁主干:尽管当前 427950a43a 通过了 canary premerge --tier quick 与 290 条既有单测,且前序某审查已发出 APPROVE,但实测证实只要共享 Goal 目录开启 progress_review.mode='assist'(或 replan_after_effective_turns)并含一条旧实例历史 ACK,同 Turn 重入即以 rc=1 heartbeat_receipt_identity_conflict 阻塞后续续跑。当前远端 CI 上尚有 2 项 IN_PROGRESS、1 项 QUEUED(及 2 项已取消)运行记录。

我的整体评价 / Verdict

427950a43a 成功消除了 goal_frontier 复杂度棘轮超限并保留了同秒写回与 selected-todo 旧实例 ACK 隔离的全部正向收益,但 live_decision.py 二次重算漏传 external_progress_review / effective_turn_cadence 的 P1 缺陷在真实 quota should-run 重入链路中必然复现 heartbeat_receipt_identity_conflict 崩溃,不能放行合并。visual_review:not_applicable(原因:仅涉及控制面配额判定、历史 ACK 过滤、run compaction 与 CLI/unit 测试,不涉及任何前端页面或渲染视图变更。;未验证范围:none)。请作者在 _restore_replan_obligation_without_foreign_acks 补全上下文透传(或将过滤前置到状态投影前)并补充相应 CLI 重入回归测试后再行复审。

English verdict: REQUEST_CHANGES at exact head 427950a; while commit 427950a fixes the earlier goal_frontier maintainability ratchet failure (57 <= 60 decision points) and preserves the P2 fixes on qualify_replan_writeback and selected-todo retired-ACK isolation (290 passed across 5 control-plane/ratchet suites and canary premerge --tier quick passes), _restore_replan_obligation_without_foreign_acks (loopx/control_plane/quota/live_decision.py:669-733) still omits external_progress_review and effective_turn_cadence when calling attach_active_state_project_asset_fields, regressing real-CLI progress_review reentry from rc=0 autonomous_replan_required (513b6f168a) to rc=1 heartbeat_receipt_identity_conflict (427950a43a).

Rebuilding the open review after a retired ACK must use the same assist
policy and effective-turn cadence as the original status projection.

Signed-off-by: Duang777 <duangjl007@gmail.com>
loopx-agent
loopx-agent previously approved these changes Nov 18, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google (self_reported)

已针对 PR #8975 最新 exact head ac51bf333044f8232b13f355df760a0b9ac1064b 完成独立重审、代码对照与本地复测(审查结论:APPROVE,无 P0/P1/P2 阻断问题;前序审查指出的 live_decision.py P1 重入缺陷已在最新提交修复)。

动机 / Motivation

受影响调用方与运维者:共享同一 goal_id 目录(goals/<goal_id>/rollout-event-log.jsonl 与 goals/<goal_id>/runs/index.jsonl)的多实例 Goal、别名(alias,无 goal_ref)与精确 goal_ref 配额调用方,以及执行 quota should-run 与 refresh-state(尤其开启 progress_review 或 replan_after_effective_turns)的运维者与 Agent。

修改前(main 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d 与上一审查头 427950a43a):首先在 main 上,autonomous_replan_ack.py 的历史 ACK 回写顺序读取器与 run_compaction.py 未按 goal_ref 隔离或保留实例身份,导致退役实例的先序 refresh_state 抢先绑定并触发 heartbeat_receipt_identity_conflict(exit 1);其次在上一版提交 427950a43a 中,_restore_replan_obligation_without_foreign_acks 在清除他实例 ACK 后调用 attach_active_state_project_asset_fields 时漏传 external_progress_review 与 effective_turn_cadence,使开启 progress_review.mode='assist' 的 Turn 在同 Turn 重入时以 rc=1 heartbeat_receipt_identity_conflict 退化。修改后(ac51bf333044f8232b13f355df760a0b9ac1064b):新增参数透传 registry_goal、registry_path 与 runtime_root,按与 attention_queue.py 一致的方式构造 external_progress_review_context 与 effective_turn_cadence_context 并传入 attach_active_state_project_asset_fields,同时在 tests/control_plane/test_quota_settlement_cli.py 新增 test_progress_review_reentry_keeps_the_admitted_obligation_beside_a_retired_ack 覆盖该重入路径。

可观测结果:在 ac51bf333044f8232b13f355df760a0b9ac1064b 上实测:ruff check(9 个变更文件)全部通过;全仓 mypy(17 个源文件)0 错误;tests/control_plane_ts/replan_semantics.test.ts 41 passed;tests/control_plane/test_autonomous_replan_ack.py 与 tests/control_plane/test_quota_settlement_cli.py(-k "ack or retired or progress_review_reentry or same_second")60 passed(167 deselected);tests/control_plane/test_effective_turn_replan.py、tests/test_progress_review_criterion_binding.py 与 tests/control_plane/test_goal_frontier_replan_rules.py 89 passed;突变对照测试将 live_decision.py 新补入的 external_progress_review=review 注释掉后,test_progress_review_reentry_keeps_the_admitted_obligation_beside_a_retired_ack 按预期在同 Turn 第二次 quota should-run 以 rc=1(decision=skip)失败;loopx canary premerge --tier quick --from-git-diff --git-diff-base 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d(含 4 项直接检查、py_compile 与 3 项金丝雀)与 loopx check --scan-path(9 文件)均全部通过(errors=0, failures=0)。

非目标边界:本 PR 不修改 #8907 准入时钟(admission_event_id)语义,不改变通用 status 对 latest_agent_replan_ack 的只读投影契约,亦不关闭 #8907 或 #8804。

改动思路 / Approach

架构与放置判断:沿用 loopx/control_plane/work_items/autonomous_replan_ack.py 作为历史 ACK 与写入顺序读取边界、semantic_history.py::receipt_bound_replan_ack_history 承担 receipt_bound_replan_ack_candidates 选择(使 build_goal_frontier_projection_context_from_status 保持在可维护性棘轮预算内),以及 live_decision.py::_restore_replan_obligation_without_foreign_acks 在 receipt_bound_replay_phase == OPEN 时按 goal_ref 过滤并恢复原 Turn 义务,全部复用现有控制面所有权边界与 TypeScript quotaOwnerOwnsProjection 语义(alias 仅匹配缺失 goal_ref 的行,exact 校验字符串化 exact_goal_ref 一致性),未引入新持久字段或并行策略所有权。

当前 PR 边界:完整范围(513b6f168a405d5c071c79ae23fb18d2b4f5ae5d..ac51bf333044f8232b13f355df760a0b9ac1064b,9 文件 +676 / -20)聚焦 GoalRef 隔离、compact 字段保留、semantic_history 候选收窄、live_decision 重入恢复上下文补全与双后端(file/sqlite)+ assist 重入回归测试;相对 427950a43a 仅增补 live_decision.py 上下文透传与对应的 CLI 回归测试,边界收敛。

场景 / 调用路径 基线 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d / 旧头 427950a43a 当前 exact head ac51bf333044f8232b13f355df760a0b9ac1064b
精确 goal_ref 同秒历史 ACK 混入退役实例先序写回 writeback_follows_admission 被退役实例事件误判为 false(heartbeat_receipt_identity_conflict) _owner_goal_ref + _record_owned_by_goal_ref 隔离非己方行,准确记录 historical_ack_recorded
仅存在退役实例历史 ACK(file / sqlite) 非受限历史可能回退至退役实例 ACK receipt_bound_replan_ack_history 保留显式空候选列表,quota should-run 保持 replan_required
progress_review.mode='assist' 同 Turn 重入伴随退役 ACK 427950a43a 漏传上下文导致重算丢失义务并退化为 rc=1 透传 external_progress_review 与 effective_turn_cadence,第二次 quota should-run 保持 rc=0 与原 obligation_id

具体改动 / Changes

本次 diff(513b6f168a405d5c071c79ae23fb18d2b4f5ae5d..ac51bf333044f8232b13f355df760a0b9ac1064b)共修改 9 个文件(+676 / -20,未涉及 RFC 文件):

  1. loopx/control_plane/quota/live_decision.py(+91 / -1):在 _restore_replan_obligation_without_foreign_acks 新增 registry_goal、registry_path、runtime_root 参数,从 external_progress_review_context 与 effective_turn_cadence_context 还原上下文后传入 attach_active_state_project_asset_fields,并向 load_receipt_replan_ack_candidates 与 _restore_replan_obligation_without_foreign_acks 透传 goal_ref。
  2. loopx/control_plane/work_items/autonomous_replan_ack.py(+117 / -9):新增 _parsed_exact_goal_ref、_owner_goal_ref、_record_owned_by_goal_ref、drop_unowned_recorded_replan_acks 与 _owned_records,在 _admission_event_index、_source_run、_expected_todo_receipt、_writeback_event_is_bound、_original_writeback_event_index、attach_historical_ack_writeback_order、historical_ack_candidates_with_writeback_order 与 load_receipt_replan_ack_candidates 强制按 goal_ref 隔离。
  3. loopx/control_plane/goals/goal_frontier/semantic_history.py(+32 / -0)与 loopx/control_plane/goals/goal_frontier/__init__.py(+4 / -7):新增 receipt_bound_replan_ack_history,在存在 receipt_bound_replan_obligation_id 且传入 list 类型候选时严格采用受限候选列表(含空列表)。
  4. loopx/control_plane/work_items/semantic_replan_writeback.py(+13 / -3)、loopx/control_plane/runtime/run_compaction.py(+1 / -0)与 loopx/state_refresh.py(+1 / -0):在 RUN_BASE_COMPACT_FIELDS 保留 "goal_ref",并在 qualify_replan_writeback / enforce_open_replan_writeback / qualify_refresh_replan_writeback 与 refresh_state_run 中按 goal_ref 过滤 owned_history 后再判定写入。
  5. tests/control_plane/test_autonomous_replan_ack.py(+107 / -0)与 tests/control_plane/test_quota_settlement_cli.py(+310 / -0):补充同秒双实例写入顺序隔离、仅退役实例 ACK(file 与 sqlite)以及 test_progress_review_reentry_keeps_the_admitted_obligation_beside_a_retired_ack CLI 回归测试。

关键代码讲解

  1. _restore_replan_obligation_without_foreign_acks(loopx/control_plane/quota/live_decision.py:669-751):当 receipt_bound_replay_phase is OPEN 且 goal["latest_runs"] 命中非本实例已记录 ACK 时,先剔除他实例 ACK 与对应 semantic_history 残留,再基于 registered_goal(回退 {"id": goal_id})构造 external_progress_review_context(source_goal, runtime_root) 与 effective_turn_cadence_context(...) 交由 attach_active_state_project_asset_fields 重建 autonomous_replan_obligation,保证与 attention_queue.py 初次投影上下文一致。
  2. _record_owned_by_goal_ref(loopx/control_plane/work_items/autonomous_replan_ack.py:305-318):alias 所有者(owner is None)仅匹配 "goal_ref" not in record 的行;exact 所有者仅匹配经 exact_goal_ref 校验且相等的 goal_ref,与 TypeScript quotaOwnerOwnsProjection 保持精确语义对齐。
  3. receipt_bound_replan_ack_history(loopx/control_plane/goals/goal_frontier/semantic_history.py:49-79):避免当受限 receipt_bound_replan_ack_candidates 为空列表 [] 时回退到全局 latest_autonomous_replan_ack_from_status_payload,同时保持 build_goal_frontier_projection_context_from_status 在棘轮限制内。

对主干的风险 / Risks

  • 无 P0/P1/P2 阻断性缺陷:当前 exact head 的全部本地静态检查、TypeScript 语义单测、149 项控制面与回归 pytest、突变敏感性校验与 quick premerge 金丝雀均已通过。
  • 远端 CI 与非阻断性提示:远端 CI 中 kernel-static-checks 失败于主干既有问题 tests/test_chat_manager_model_adoption.py:416(F811 Redefinition of unused steward,本 PR 未触及该文件),引发下游 checks、pytest、stage2c-correctness-e2e 与 merge-gate 级联失败或跳过,而 browser (1-3/3) 仍在运行;此外 live_decision.py:745 若传入非标准空 dict goal_ref={} 时会因 all(...) 为真透传空映射而非 None(当前 CLI/caller 仅传入 None 或校验后的 exact_goal_ref),以及 goal_frontier/__init__.py:1681 在 owned 非空时存在无害的重复候选读取(TS 侧首次匹配即返回),两者均属非阻断残留细节。在合并前需先修复主干 lint 或完成合并就绪检查。

我的整体评价 / Verdict

提交 ac51bf333044f8232b13f355df760a0b9ac1064b 精确修复了上一版 427950a43a 在 _restore_replan_obligation_without_foreign_acks 漏传 external_progress_review 与 effective_turn_cadence 的 P1 回归,保持了 GoalRef 历史 ACK 写回顺序隔离、goal_frontier 棘轮预算与 file/sqlite 双权威后端语义一致性,本地控制面单测、CLI 重入测试、突变校验及 quick premerge 门禁均通过。visual_review:not_applicable(原因:仅涉及控制面配额判定、历史 ACK 过滤、run compaction 与 CLI/unit 测试,不涉及任何前端页面或渲染视图变更。;未验证范围:none)。同意放行本 PR 审查结论为 APPROVE(合并仍需等待主干 lint 修复后的 CI 与维护者合入授权)。

English verdict: APPROVE exact head ac51bf3; commit ac51bf3 resolves the prior P1 regression in live_decision._restore_replan_obligation_without_foreign_acks by forwarding external_progress_review and effective_turn_cadence alongside GoalRef-fenced ACK isolation across autonomous_replan_ack.py, semantic_history.py, semantic_replan_writeback.py, and run_compaction.py, verified locally via ruff (9 changed files), 17-file mypy, 41 TS replan_semantics tests, 149 control-plane/CLI pytest assertions, a sensitivity mutation check (rc=1), and canary premerge --tier quick (failures=0); remote kernel-static-checks failure (tests/test_chat_manager_model_adoption.py:416 F811) is pre-existing on main (067ad42cc4).

@mergify

mergify Bot commented Nov 18, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @Duang777.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 18, 2026
…-ack-writeback-goalref-4922

Signed-off-by: Duang777 <duangjl007@gmail.com>
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 18, 2026

@loopx-agent loopx-agent left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, max)

独立评审提交 7771509f92ff672474214b85d6f21adb3ce1a376,完整差异使用比较基线 b93b5f9438e494de43e72c52c38ad213fbf7dde8。

动机 / Motivation

恢复已准入的重规划轮次时,Agent 和操作者需要从原任务与回执继续工作。更换 Goal 实例后,同名历史里可能保留旧实例的确认。

若只有旧实例的记录,基线会报告本轮确认已记录。本轮应该保留重规划义务,直到当前实例有归属明确的确认。

同一个周期评审在 File 和 SQLite 上恢复到原义务。机器默认周期和 Goal 显式周期都通过,原轮次的回执没有重建,配额没有追加扣减。

本次范围是现有 quota should-run 与 refresh-state 的原轮次恢复。保留已有准入时钟和结算身份。

改动思路 / Approach

按 GoalRef 对原始历史来源做归属过滤,TypeScript 继续判断确认的时间与语义。恢复重算沿用现有进度评审和有效轮次周期。

当前改动交付同轮确认恢复及写回归属,保持实际准入时间、原义务和一次性结算。

仅依靠时间不能分辨共享日志中新旧实例。当前实现先过滤有归属的记录,再用已有准入时钟校验顺序。既有 run compaction 保留实例身份,原写回 owner 继续裁决。

具体改动 / Changes

完整差异 9 个文件,+680/−22。7 个运行时路径与 2 个测试文件。修改读取和重入资格,未改平台流程或回执的字段集合。

以 b93b5f9438e494de43e72c52c38ad213fbf7dde8 的契约评估当前范围。 docs/reference/protocols/goal-vision-replan-contract-v0.md

  • ack-freshness 对应确认必须依附原写回身份和时间顺序,覆盖截至其自身持久写回的义务。 已通过同秒写回、旧实例领先事件与原准入时间回归。
  • same-turn-settlement 对应只能按原 Goal、Agent、Todo 和 Turn 恢复当前义务及结算步骤。 已通过四组周期评审对照、原回执和扣额计数。
  • current-source-only 对应精确 Goal 实例屏蔽已退役实例的来源,已绑定来源仍可验证。 已通过File/SQLite-only retired、精确实例与 alias 对照。
  • cadence-source 对应配额与写回使用相同有效周期和原审查上下文。 已通过机器默认、显式周期与 progress-review assist 回归。

关键代码讲解

  • attach_historical_ack_writeback_order 只在当前历史归属内比较真实准入与原写回的顺序,同时保留 admission_event_id。 源码
  • receipt_bound_replan_ack_history 显式空候选保留为无合法 ACK,无候选投影参数保留旧查找。 源码
  • _restore_replan_obligation_without_foreign_acks 清理已退役 ACK 影响后,用原进度评审和有效轮次条件重算。 源码
  • qualify_refresh_replan_writeback 从 refresh-state 传递真实 GoalRef 与原准入证据,复用已有写回和一次扣额约束。 源码
  • RUN_BASE_COMPACT_FIELDS 持久 run 投影保留已有 GoalRef,不新建历史记录种类。 源码

对主干的风险 / Risks

File/SQLite 与机器默认/Goal 覆盖四种对照,基线的 4 个结果错误选成 historical_ack_recorded。当前 4 个保留原义务、原一份准入回执及两次既有扣额。

上一轮复杂度问题由共享 semantic-history 收口,当前标准预合并的维护性 ratchet 通过。File 与 SQLite 定向覆盖只存在旧确认、己方同秒确认、旧写回先出现和同轮升级仍用原准入事件。

比较基线四例的外层返回码均为 0,具体分支却是 historical_ack_recorded。因此对照检查按原计划分支和义务验证。新头四例仍需要原写回。原准入时钟的合并来源已核对。 #8907

语义与 CI 对齐

复用 GoalRef 与已有 replan 状态,Python 读取边界做来源限制,TypeScript 持有原语义及准入义务。

标准预合并 6 项直接检查和 18 项选定检查通过。独立聚焦 Python 23 项、TS 212 项、控制面类型检查、mypy 17 个源文件及变更 Python Ruff 均通过。

这些用例使用隔离的真实 File/SQLite 存储与原生 CLI。托管 CI 状态未知。

扩大验证中,两项默认周期用例在比较基线 b93b5f9438e494de43e72c52c38ad213fbf7dde8 和当前头的同一断言均报 KeyError: 'vision_authoring'。断言读取的是精简 Turn envelope 的内联说明字段。该序列化代码与测试在本 PR 的差异中均未改动。需恢复原义务的四条 File/SQLite 对照另行验证了同一写回指令和回执。 基线序列化

我的整体评价 / Verdict

批准此源版的原轮次恢复修复。长程工作保留待做评审,原轮次可以继续写回,操作员无需用新轮次避开身份冲突。

涉及 CLI 和配额历史恢复,现有消费者通过原结构化命令与结果继续工作。没有渲染路径的变更。 无额外发布或安装资格结论。合并条件需以平台的当前评审状态读回。

English verdict: APPROVE at 7771509. Historical ACK recovery preserves the admitted obligation, instance ownership, and original writeback order on File and SQLite.

@loopx-agent
loopx-agent merged commit 07722b1 into main Nov 18, 2026
41 of 70 checks passed
@loopx-agent
loopx-agent deleted the cursor/fix-historical-ack-writeback-goalref-4922 branch November 18, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants